package com.lightsh.common;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.util.Log;

import com.lightsh.db.DbDataHelper;
import com.lightsh.db.MyDbHelper;
import com.lightsh.list.AbstractListItem;
import com.lightsh.utility.Constants;

public class NoteItem extends AbstractListItem{
	
	public static final int INVALID_ID = -1;
	public static final int NOTE_TYPE_TEXT = 0;

	private static final long serialVersionUID = 1L;
	private long mId;
	private int mType = NOTE_TYPE_TEXT;
	private long mLastlyTime;
	private long mCreateTime;
	private String mText;
	
	/**
	 *  not used
	 */
	private String mKey;
	
	private ArrayList<CharacterItem> mCharacters;
	
	public NoteItem(long id, String key, long time, String text, long createTime){
		mId = id;
		mLastlyTime = time;
		mText = text;
		mCreateTime = createTime;
		mKey = key;
	}
	
	public long getLastlyTime(){
		return mLastlyTime;
	}
	public long getCreateTime(){
		return mCreateTime;
	}
	public long getId(){
		return mId;
	}
	public String getText(){
		return mText;
	}
	public String getKey(){
		return mKey;
	}
	public int getType(){
		return mType;
	}
	public List<CharacterItem> getCharactersList(Context context){
		if(mCharacters == null){
			initCharactersList(context);
		}
		return mCharacters;
	}
	
	private void initCharactersList(Context context){
		if(mCharacters != null){
			mCharacters.clear();
		}else{
			mCharacters = new ArrayList<CharacterItem>();
		}
		DbDataHelper.getNoteCharacterList(context, mId, mCharacters);
	}
}
